package com.yuanfengPlus.goodsManage.goodsBrandManage.controller;

import com.yuanfengPlus.goodsManage.goodsBrandManage.model.GoodsBrand;
import com.yuanfengPlus.goodsManage.goodsBrandManage.service.GoodsBrandService;
import com.yuanfengPlus.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/goodsBrand")
@Api(tags = "商品品牌管理", description = "商品品牌相关的API")
public class GoodsBrandController {

    @Autowired
    private GoodsBrandService goodsBrandService;

    @ApiOperation(value = "添加商品品牌", notes = "添加一个新的商品品牌")
    @PostMapping("/add")
    public Result addGoodsBrand(@RequestBody GoodsBrand goodsBrand) {
        return goodsBrandService.addGoodsBrand(goodsBrand);
    }

    @ApiOperation(value = "更新商品品牌", notes = "更新现有的商品品牌")
    @PutMapping("/update")
    public Result updateGoodsBrand(@RequestBody GoodsBrand goodsBrand) {
        return goodsBrandService.updateGoodsBrand(goodsBrand);
    }

    @ApiOperation(value = "查询所有商品品牌", notes = "查询所有商品品牌")
    @GetMapping("/query")
    public Result queryGoodsBrand() {
        return goodsBrandService.queryGoodsBrand();
    }

    @ApiOperation(value = "根据ID查询商品品牌", notes = "根据ID查询商品品牌")
    @ApiImplicitParam(name = "goodsBrandId", value = "商品品牌ID", required = true, dataType = "Integer", paramType = "query")
    @GetMapping("/queryById")
    public Result queryGoodsBrandById(@RequestParam Integer goodsBrandId) {
        return goodsBrandService.queryGoodsBrandById(goodsBrandId);
    }
}
